<?php
ob_start();
//include('common/db.php');
include('common/xta.php');
include('common/xpath.php');

$xta = new xta();
$xp = new xp();

function getList() {
	$all_companies = $xp->getData('company-list', 'http://money.rediff.com/gainers');
	
	foreach($all_companies as  $each_company) {
		if(isset($limit) && ($limit == $counter)) break; else $counter++;
		$company_info = $xp->getData('company-info', $each_company['url']);
		$data[] = $company_info;	
	}	
}

function getMoves() {
	$xta->load('stocks');
	$all_stocks = $xta->data['stocs'];
	foreach($all_stocks as $each_stock) {
		
		if(isset($limit) && ($limit == $counter)) break; else $counter++;
		
		$company_data = $xp->getData('stock-move', $each_stock['bsc_code']);
		$xta->data = $company_data;
		$xta->filename = $each_stock['bsc_code'];
		$xta->save('days', 'day');
	}
}

$xta->load('stocks');
$all_stocks = $xta->data['stocs'];
//print_r($all_stocks);
//die;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<link rel="stylesheet" type="text/css" href="jquery.tablesorter/themes/blue/style.css"></link>
<script type="text/javascript" src="jquery.tablesorter/jquery-latest.js"></script>
<script type="text/javascript" src="jquery.tablesorter/jquery.tablesorter.js"></script>
<script type="text/javascript">
	$(function() {
		$("#companies").tablesorter();
	});
</script>
<body>
<table id="companies" cellspacing="0" class="tablesorter">
	<thead>
		<tr>
			<th>Code</th>
			<th>Name</th>
			<th>Rank</th>			
		</tr>
	</thead>
	<tfoot>
		<tr>
			<th>Code</th>
			<th>Name</th>
			<th>Rank</th>
		</tr>
	</tfoot>
	<tbody>
	<?php foreach($all_stocks as $each_stock) { ?>
	<tr>
		<td><?=$each_stock['bsc_code']?></td>
		<td><?=$each_stock['name']?></td>
		<td><?=$each_stock['rank']?></td>	
	</tr>
	<?php } ?>
	</tbody>
</table>
</body>
</html>
